package com.jkl.nettyserver.Netty;


import io.netty.channel.ChannelDuplexHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.timeout.IdleStateEvent;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class HeartBeatHandler extends ChannelDuplexHandler {
    @Override
    public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
        if(evt instanceof IdleStateEvent){
            IdleStateEvent event=(IdleStateEvent)evt;
            switch (event.state()) {
                case READER_IDLE : {log.info("读空闲");}break;
                case WRITER_IDLE : {log.info("写空闲");}break;
                case ALL_IDLE : {log.info("读写空闲");}break;
            }
        }
    }
}
